package ;

import com.grouuu.core.Scene;
import nme.display.Sprite;
import nme.display.Stage;
import nme.display.StageAlign;
import nme.display.StageScaleMode;
import nme.events.Event;
import nme.Lib;
import starling.core.Starling;

/**
 * ...
 * @author Grouuu
 */

class Main extends Sprite 
{
	static inline var ANTI_ALIAS:Int = 1;
	static private var stage:Stage;
	
	private var starling:Starling;
	
	public function new() 
	{
		super();
		
		#if iphone
			Lib.current.stage.addEventListener(Event.RESIZE, init);
		#else
			addEventListener(Event.ADDED_TO_STAGE, init);
		#end
	}
	
	static public function main():Void
	{
		stage = Lib.current.stage;
		
		stage.scaleMode = StageScaleMode.NO_SCALE;
		stage.align = StageAlign.TOP_LEFT;
		
		Lib.current.addChild(new Main());
	}

	private function init(event:Event):Void
	{
		starling = new Starling(Scene, stage);
		starling.antiAliasing = Main.ANTI_ALIAS;
		starling.start();
	}
}
